package com.lvmama.pangolin.controller;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.lvmama.pangolin.entity.CommodityRel;
import com.lvmama.pangolin.entity.mt.MTTicketCommodityItem;
import com.lvmama.pangolin.mt.service.MTTicketCommodityItemsService;
import com.lvmama.pangolin.util.CommodityRelationshipUtil;
import com.lvmama.pangolin.util.ProductRelationshipHotelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lvmama.pangolin.entity.CommodityConditionVO;
import com.lvmama.pangolin.entity.ProductConditionVO;
import com.lvmama.pangolin.entity.RelevanceProduct;
import com.lvmama.pangolin.entity.hotel.HotelCommodityDetail;
import com.lvmama.pangolin.entity.link.TicketCommodityLink;
import com.lvmama.pangolin.entity.link.TicketCommodityLinkView;
import com.lvmama.pangolin.entity.lmm.LMMTicketCommodity;
import com.lvmama.pangolin.entity.qnr.QNRTicketCommodityItem;
import com.lvmama.pangolin.entity.tc.TCommodityItem;
import com.lvmama.pangolin.entity.tn.TNTicketCommodityItem;
import com.lvmama.pangolin.entity.xc.XCTicketCommodityItem;
import com.lvmama.pangolin.hotel.service.HotelCommodityDetailService;
import com.lvmama.pangolin.lmm.service.LMMTicketCommodityService;
import com.lvmama.pangolin.qnr.service.QNRTicketCommodityItemsService;
import com.lvmama.pangolin.service.RelevanceCommodityService;
import com.lvmama.pangolin.service.RelevanceProductService;
import com.lvmama.pangolin.tc.service.TCCommodityItemsService;
import com.lvmama.pangolin.tn.service.TNTicketCommodityItemsService;
import com.lvmama.pangolin.xc.service.XCTicketCommodityItemsService;



@Controller
@RequestMapping("/datashow")
public class MatchCommodityController {
	
	@Autowired
	private LMMTicketCommodityService lmmCommodityService;
	@Autowired
	private TCCommodityItemsService tcCommodityService;
	@Autowired
	private XCTicketCommodityItemsService xcCommodityService;
	@Autowired
	private TNTicketCommodityItemsService tnCommodityService;
	@Autowired
	private QNRTicketCommodityItemsService qnrCommodityService;
	//新增美团
	@Autowired
	private MTTicketCommodityItemsService mtCommodityService;
	@Autowired
	private RelevanceProductService relevanceProductService;
	@Autowired
	private RelevanceCommodityService relevanceCommodityService;
	@Autowired
	private HotelCommodityDetailService hotelCommodityService;

	@Autowired
	private CommodityRelationshipUtil commodityRelationshipUtil;

	@Autowired
	private ProductRelationshipHotelUtil productRelationshipHotelUtil;
	private static final String LMMCODE="LMM_C_CODE";

	private static final String BUSINESS_HOTEL="HOTEL";
	/**
	 * 基本思路：
	 * 1.查询lmm的所有商品信息，
	 * 2.根据lmm商品id查询商品关联表，将关联信息封装到关联展示对象中（prod_id,comm_id,comm_name,comm_price,已经竞品的comm_id,comm_name,comm_price）
	 * 3.跳转商品展示页面
	 * @param model
	 * @param co
	 * @param sceneryName
	 * @param
	 * @return
	 */
	@RequestMapping("/product_list")
	public String commodityList(ModelMap model,CommodityConditionVO co,String sceneryName,String prodPageNum,String productIdVO,String sceneryNameVO,String cityCode,String starLevel,String businessCode){
		ProductConditionVO pc=new ProductConditionVO();
		pc.setProductId(productIdVO);
		pc.setSceneryName(sceneryNameVO);
		pc.setCityCode(cityCode);
		pc.setBusinessCode(businessCode);
		pc.setStarLevel(starLevel);
//		if ()
//		String businessCode=pc.getBusinessCode();

		model.addAttribute("productConditionVO",pc);	
		/**
		 * 景点名称
		 */
		model.addAttribute("sceneryName",sceneryName);
		/**
		 * 根据productId，查询所有关联的景点，
		 * 显示产品已经关联的商品
		 */
		RelevanceProduct relevanceProduct=relevanceProductService.viewRelevance(co.getProductId(),businessCode);

		model.addAttribute("relevanceProduct",relevanceProduct);
		/**
		 * 根据查询条件返回lmm商品列表
		 */
		model.addAttribute("commConditionVO", co);
		model.addAttribute("prodPageNum",prodPageNum);
		/**
		 * 创建一个list用来存放lmm所有商品的关联信息，每个商品的关联信息封装成一个对象，以便前台展示
		 */
		List<TicketCommodityLinkView> ptcs=new ArrayList<TicketCommodityLinkView>();
		
		if(businessCode==null||"".equals(businessCode)||"TICKET".equals(businessCode)){
			List<LMMTicketCommodity>commList=lmmCommodityService.selectByProdId(co);
			PageInfo<LMMTicketCommodity> page=new PageInfo<LMMTicketCommodity>(commList);
			PageHelper.startPage(co.getPage(), co.getPageSize());
			model.addAttribute("page",page);
			/**
			 * 遍历lmm商品列表，返回每个商品的关联信息，并将页面上要显示的一条记录封装成一个对象
			 */
			for (int index=0;index<commList.size();index++){
				/**
				 * 获取一条lmm的商品信息
				 */
				LMMTicketCommodity lcomm=commList.get(index);
				/**
				 * 对于一个lmm的商品，创建一个商品关联展示对象，并将lmm的商品信息封装到对象中
				 */
				TicketCommodityLinkView tclv=new TicketCommodityLinkView();
				tclv.setCommodity_id(lcomm.getCommodityId());
				tclv.setCommodity_name(lcomm.getCommodityName());
				tclv.setCommodity_price(lcomm.getSalePrice());
				/**
				 * 创建一个商品关联对象，用于存放查询条件（商品id,产品id）
				 */
				TicketCommodityLink commLink=new TicketCommodityLink();
				commLink.setCommodity_id(lcomm.getCommodityId().trim());
				commLink.setProd_id(lcomm.getProductId().trim());
				/**
				 * 根据条件(商品id,产品id)来查询，一个商品对应的所有关联记录（最多四条、分别对应四个竞品的关联关系，最少零条）
				 */
				List<TicketCommodityLink> tcls=relevanceCommodityService.viewCommodityLink(commLink);
				/**
				 * 将0-4条纵向的商品关联信息封装到一条记录中
				 */
				if(tcls!=null&&tcls.size()>0){
					/**
					 * 遍历该商品对应的关联记录
					 */
					for(int j=0;j<tcls.size();j++){
						/**
						 * 得到一条商品关联记录，并将此记录封装到页面展示的对象中
						 */
						TicketCommodityLink cl=tcls.get(j);
						if("xc".equals(cl.getCompany_code())){
							tclv.setCommodity_id_xc(cl.getRel_commodity_id());
							tclv.setCommodity_name_xc(cl.getRel_commodity_name());
						}else if("tn".equals(cl.getCompany_code())){
							tclv.setCommodity_id_tn(cl.getRel_commodity_id());
							tclv.setCommodity_name_tn(cl.getRel_commodity_name());
//							TNTicketCommodityItem tnComm=tnCommodityService.selectByProdCommId(cl.getRel_prod_id(), cl.getRel_commodity_id());
//							tclv.setCommodity_id_tn(tnComm.getCommodity_id());
//							tclv.setCommodity_name_tn(tnComm.getCommodity_name());
//							tclv.setCommodity_price_tn(tnComm.getSale_price());
						}else if("tc".equals(cl.getCompany_code())){
							tclv.setCommodity_id_tc(cl.getRel_commodity_id());
							tclv.setCommodity_name_tc(cl.getRel_commodity_name());
						}else if("qnr".equals(cl.getCompany_code())){
							tclv.setCommodity_id_qnr(cl.getRel_commodity_id());
							tclv.setCommodity_name_qnr(cl.getRel_commodity_name());
						}else if("mt".equals(cl.getCompany_code())){//新增美团
							tclv.setCommodity_id_mt(cl.getRel_commodity_id());
							tclv.setCommodity_name_mt(cl.getRel_commodity_name());
						}
					}
					
				}
				ptcs.add(tclv);
			}
		}else if("HOTEL".equals(businessCode)){
			List<HotelCommodityDetail>commList=hotelCommodityService.findByCommVO(co);
			PageInfo<HotelCommodityDetail> page=new PageInfo<HotelCommodityDetail>(commList);
			PageHelper.startPage(co.getPage(), co.getPageSize());
			model.addAttribute("page",page);
			/**
			 * 遍历lmm商品列表，返回每个商品的关联信息，并将页面上要显示的一条记录封装成一个对象
			 */
			for (int index=0;index<commList.size();index++){
				/**
				 * 获取一条lmm的商品信息
				 */
				HotelCommodityDetail lcomm=commList.get(index);
				/**
				 * 对于一个lmm的商品，创建一个商品关联展示对象，并将lmm的商品信息封装到对象中
				 */
				TicketCommodityLinkView tclv=new TicketCommodityLinkView();
				tclv.setCommodity_id(lcomm.getCommodityId());
				tclv.setCommodity_name(lcomm.getCommodityName());
				tclv.setCommodity_price(lcomm.getSalePrice());
				tclv.setCommodity_type(lcomm.getRoomType());
//				tclv.setCommodity_type(lcomm.getCommodityType());
				/**
				 * 创建一个商品关联对象，用于存放查询条件（商品id,产品id）
				 */
				TicketCommodityLink commLink=new TicketCommodityLink();
				commLink.setCommodity_id(lcomm.getCommodityId().trim());
				commLink.setProd_id(lcomm.getProductId().trim());
				/**
				 * 根据条件(商品id,产品id)来查询，一个商品对应的所有关联记录（最多四条、分别对应四个竞品的关联关系，最少零条）
				 */
				List<TicketCommodityLink> tcls=relevanceCommodityService.viewCommodityLink(commLink);
				//修改后的接口
				CommodityRel commodityRel = new CommodityRel();
				commodityRel.setCommodity_id(lcomm.getCommodityId().trim());
				commodityRel.setProd_id(lcomm.getProductId().trim());
				commodityRel.setBusiness_code(BUSINESS_HOTEL);

				List<CommodityRel> _tcls = relevanceCommodityService.queryByCommodityRel(commodityRel);
				if(_tcls!=null&&!_tcls.isEmpty())
				{
					for(int j=0;j<_tcls.size();j++)
					{
						CommodityRel cr = _tcls.get(j);
						if("xc".equals(cr.getCompany_code())){
							tclv.setCommodity_id_xc(cr.getRel_commodity_id());
							tclv.setCommodity_name_xc(cr.getRel_commodity_name());
						}else if("tn".equals(cr.getCompany_code())){
							tclv.setCommodity_id_tn(cr.getRel_commodity_id());
							tclv.setCommodity_name_tn(cr.getRel_commodity_name());
						}else if("tc".equals(cr.getCompany_code())){
							tclv.setCommodity_id_tc(cr.getRel_commodity_id());
							tclv.setCommodity_name_tc(cr.getRel_commodity_name());
						}else if("qnr".equals(cr.getCompany_code())){
							tclv.setCommodity_id_qnr(cr.getRel_commodity_id());
							tclv.setCommodity_name_qnr(cr.getRel_commodity_name());
						}else if("el".equals(cr.getCompany_code())){
							tclv.setCommodity_id_el(cr.getRel_commodity_id());
							tclv.setCommodity_name_el(cr.getRel_commodity_name());
						}//新增美团
						else if("mt".equals(cr.getCompany_code())){
							tclv.setCommodity_name_mt(cr.getRel_commodity_name());
						}
					}
				}
//				/**
//				 * 将0-4条纵向的商品关联信息封装到一条记录中
//				 */
//				if(tcls!=null&&tcls.size()>0){
//					/**
//					 * 遍历该商品对应的关联记录
//					 */
//					for(int j=0;j<tcls.size();j++){
//						/**
//						 * 得到一条商品关联记录，并将此记录封装到页面展示的对象中
//						 */
//						TicketCommodityLink cl=tcls.get(j);
//						if("xc".equals(cl.getCompany_code())){
//							tclv.setCommodity_id_xc(cl.getRel_commodity_id());
//							tclv.setCommodity_name_xc(cl.getRel_commodity_name());
//						}else if("tn".equals(cl.getCompany_code())){
//							tclv.setCommodity_id_tn(cl.getRel_commodity_id());
//							tclv.setCommodity_name_tn(cl.getRel_commodity_name());
//						}else if("tc".equals(cl.getCompany_code())){
//							tclv.setCommodity_id_tc(cl.getRel_commodity_id());
//							tclv.setCommodity_name_tc(cl.getRel_commodity_name());
//						}else if("qnr".equals(cl.getCompany_code())){
//							tclv.setCommodity_id_qnr(cl.getRel_commodity_id());
//							tclv.setCommodity_name_qnr(cl.getRel_commodity_name());
//						}else if("el".equals(cl.getCompany_code())){
//							tclv.setCommodity_id_el(cl.getRel_commodity_id());
//							tclv.setCommodity_name_el(cl.getRel_commodity_name());
//						}//新增美团
//						else if("mt".equals(cl.getCompany_code())){
//							tclv.setCommodity_name_mt(cl.getRel_commodity_name());
//						}
//					}
//
//				}
				ptcs.add(tclv);
			}
		}
		
		model.addAttribute("ptcs",ptcs);

		return "datashow/product_list";
		}

	@RequestMapping("/selectCommodity")
	@ResponseBody
	public Object selectCommodity(String companyCode,String productId,String commodityName,String businessCode,String lvmamaCommodityId,String cityCode){
    	Map<String, Object> result = getResult();
    	RelevanceProduct relevanceProduct=relevanceProductService.viewRelevance(productId,businessCode);
    	//每个竞品分别查询是否有关联信息
    	if(businessCode==null||"".equals(businessCode)||"TICKET".equals(businessCode)){
    		//根据产品ID和商品ID查找驴妈妈对应产品信息
			LMMTicketCommodity lmmTicketCommodity = lmmCommodityService.selectByProdCommId(productId,lvmamaCommodityId);
			if(lmmTicketCommodity!=null){//城市
				lmmTicketCommodity.setCityCode(cityCode);
			}
    		if ("xc".equals(companyCode)){
    			List<XCTicketCommodityItem> commodityItems=new ArrayList<XCTicketCommodityItem>();
    			if(commodityName!=null&&!"".equals(commodityName)){
    				commodityItems=xcCommodityService.selectByProdComName(relevanceProduct.getProdIdXC(), commodityName);
    			}else{
    				commodityItems=xcCommodityService.selectByProdId(relevanceProduct.getProdIdXC());
    				
    			}
    			if(lmmTicketCommodity!=null && commodityItems!=null)//携程商品与驴妈妈商品匹配，并按照匹关联度和是否关联进行排序
				{
					commodityRelationshipUtil.matchAndSortXCTicketCommodity(lmmTicketCommodity,commodityItems);
				}
    			result.put("commodityItems", commodityItems);
    		}else if("tn".equals(companyCode)){
    			List<TNTicketCommodityItem> commodityItems=new ArrayList<TNTicketCommodityItem>();
    			if(commodityName!=null&&!"".equals(commodityName)){
    				commodityItems =tnCommodityService.selectByProdComName(relevanceProduct.getProdIdTN(), commodityName);
    			}else{
    				commodityItems= tnCommodityService.selectByProdId(relevanceProduct.getProdIdTN());
    			}
				if(lmmTicketCommodity!=null && commodityItems!=null)//途牛商品与驴妈妈商品匹配，并按照关联度和是否关联进行排序
				{
					commodityRelationshipUtil.matchAndSortTNTicketCommodity(lmmTicketCommodity,commodityItems);
				}
    			result.put("commodityItems", commodityItems);
    		}else if("tc".equals(companyCode)){
    			List<TCommodityItem>commodityItems=new ArrayList<TCommodityItem>();
    			if(commodityName!=null&&!"".equals(commodityName)){
    				commodityItems=tcCommodityService.selectByProdComName(relevanceProduct.getProdIdTC(), commodityName);
    			}else{
    				commodityItems=tcCommodityService.selectByProdId(relevanceProduct.getProdIdTC());
    			}
    			if(lmmTicketCommodity!=null &&commodityItems!=null)//同城商品与驴妈妈商品匹配，并按照关联度和是否关联进行排序
				{
					commodityRelationshipUtil.matchAndSortTCTicketCommodity(lmmTicketCommodity,commodityItems);
				}

    			 result.put("commodityItems", commodityItems);
    			 
    		}else if("qnr".equals(companyCode)){
    			List<QNRTicketCommodityItem>commodityItems=new ArrayList<QNRTicketCommodityItem>();
    			if(commodityName!=null&&!"".equals(commodityName)){
    				commodityItems=qnrCommodityService.selectByProdComName(relevanceProduct.getProdIdQNR(), commodityName);
    			}else{
    				commodityItems=qnrCommodityService.selectByProdId(relevanceProduct.getProdIdQNR());
    			}
    			if(lmmTicketCommodity!=null && commodityItems!=null)//去哪儿商品与驴妈妈商品匹配，并按照关联度和是否关联进行排序
				{
					commodityRelationshipUtil.matchAndSortQNRTicketCommodity(lmmTicketCommodity,commodityItems);
				}
    			 result.put("commodityItems", commodityItems);
    		}else if("mt".equals(companyCode)){//新增美团

				List<MTTicketCommodityItem>commodityItems=new ArrayList<MTTicketCommodityItem>();
				if(commodityName!=null&&!"".equals(commodityName)){
					commodityItems=mtCommodityService.selectByProdComName(relevanceProduct.getProdIdMT(), commodityName);
				}else{
					commodityItems=mtCommodityService.selectByProdId(relevanceProduct.getProdIdMT());
				}

				if(lmmTicketCommodity!=null && commodityItems!=null)//美团商品与驴妈妈商品匹配，并按照关联度和是否关联进行排序
				{
					commodityRelationshipUtil.matchAndSortMTTicketCommodity(lmmTicketCommodity,commodityItems);
				}
				result.put("commodityItems", commodityItems);
			}
    	}else if("HOTEL".equals(businessCode)){//查询表：

    		List<HotelCommodityDetail> commodityItems=new ArrayList<HotelCommodityDetail>();
    		String newCompanyCode=companyCode.toUpperCase()+"_C_CODE";


    		if("xc".equals(companyCode)){
    			commodityItems=hotelCommodityService.findByProdCommName(relevanceProduct.getProdIdXC(), commodityName,newCompanyCode);
    		}else if("tc".equals(companyCode)){
    			commodityItems=hotelCommodityService.findByProdCommName(relevanceProduct.getProdIdTC(), commodityName,newCompanyCode);
    		}else if("tn".equals(companyCode)){
				commodityItems=hotelCommodityService.findByProdCommName(relevanceProduct.getProdIdTN(), commodityName,newCompanyCode);
    		}else if("qnr".equals(companyCode)){
    			commodityItems=hotelCommodityService.findByProdCommName(relevanceProduct.getProdIdQNR(), commodityName,newCompanyCode);
    		}else if("el".equals(companyCode)){
    			commodityItems=hotelCommodityService.findByProdCommName(relevanceProduct.getProdIdEL(), commodityName,newCompanyCode);
    		}else if("mt".equals(companyCode)){//新增美团
				commodityItems=hotelCommodityService.findByProdCommName(relevanceProduct.getProdIdMT(), commodityName,newCompanyCode);
			}

			for(HotelCommodityDetail hotel : commodityItems)
			{
				CommodityRel commodityRel = new CommodityRel();
				commodityRel.setBusiness_code(BUSINESS_HOTEL);
				commodityRel.setCompany_code(companyCode);
				commodityRel.setRel_commodity_id(hotel.getCommodityId());
				commodityRel.setRel_prod_id(hotel.getProductId());
				List<CommodityRel> listComm = relevanceCommodityService.queryByCommodityRel(commodityRel);
				if(listComm.size()>0)
				{
					hotel.setIsLink(1);
				}else{
					hotel.setIsLink(0);
				}
			}

    		//由于修改过
    		 Collections.sort(commodityItems,new Comparator<HotelCommodityDetail>() {
					@Override
					public int compare(HotelCommodityDetail o1, HotelCommodityDetail o2) {
						if(o1.getIsLink()>o2.getIsLink()){
							return 1;
						}else if(o1.getIsLink()==o2.getIsLink()){
							return 0;
						}else{
							return -1;
						}
						
					}
				});

			HotelCommodityDetail lmmHotel = null;
    		if(productId!=null&&lvmamaCommodityId!=null)
			{//正常情况下在查询商品时不会存在两个商品id
				lmmHotel = hotelCommodityService.findByProdCommId(productId,lvmamaCommodityId,LMMCODE);
			}
			if(lmmHotel!=null)
			{
				productRelationshipHotelUtil.sortHotelCommodity(commodityItems,lmmHotel);
			}
    		 result.put("commoditys", commodityItems);
    	}
		
    	return result;
    }
	
	@RequestMapping("/linkCommodity")
	@ResponseBody
	public Object linkCommodity(TicketCommodityLink linkCommodity,String businessCode){
		Map<String, Object> result=getResult();
		
		RelevanceProduct relevanceProduct=relevanceProductService.viewRelevance(linkCommodity.getProd_id(),businessCode);
		linkCommodity.setBusiness_code(businessCode);
		if("xc".equals(linkCommodity.getCompany_code())){
			linkCommodity.setRel_prod_id(relevanceProduct.getProdIdXC());
		}else if("tn".equals(linkCommodity.getCompany_code())){
			linkCommodity.setRel_prod_id(relevanceProduct.getProdIdTN());
		}else if("tc".equals(linkCommodity.getCompany_code())){
			linkCommodity.setRel_prod_id(relevanceProduct.getProdIdTC());
		}else if("qnr".equals(linkCommodity.getCompany_code())){
			linkCommodity.setRel_prod_id(relevanceProduct.getProdIdQNR());
		}else if("el".equals(linkCommodity.getCompany_code())){
			linkCommodity.setRel_prod_id(relevanceProduct.getProdIdEL());
		}//新增美团
		else if("mt".equals(linkCommodity.getCompany_code())){
			linkCommodity.setRel_prod_id(relevanceProduct.getProdIdMT());
		}
		if(businessCode==null||"".equals(businessCode)||"TICKET".equals(businessCode)){
			if("xc".equals(linkCommodity.getCompany_code())){
				xcCommodityService.updateByProdCommId(linkCommodity.getRel_prod_id(), linkCommodity.getRel_commodity_id());
			}else if("tn".equals(linkCommodity.getCompany_code())){
				tnCommodityService.updateByProdCommId(linkCommodity.getRel_prod_id(), linkCommodity.getRel_commodity_id());
			}else if("tc".equals(linkCommodity.getCompany_code())){
				tcCommodityService.updateByProdCommId(linkCommodity.getRel_prod_id(), linkCommodity.getRel_commodity_id());
			}else if("qnr".equals(linkCommodity.getCompany_code())){
				qnrCommodityService.updateByProdCommId(linkCommodity.getRel_prod_id(), linkCommodity.getRel_commodity_id());
			}//新增美团
			else if("mt".equals(linkCommodity.getCompany_code())){
				mtCommodityService.updateByProdCommId(linkCommodity.getRel_prod_id(),linkCommodity.getRel_commodity_id());
			}
		}else if("HOTEL".equals(businessCode)){
			hotelCommodityService.setIsLinkd(linkCommodity.getCompany_code().toUpperCase()+"_C_CODE", linkCommodity.getRel_prod_id(),linkCommodity.getRel_commodity_id());
		}
		
		relevanceCommodityService.insertCommodityLink(linkCommodity);
		result.put("msg","1");
		return result;
	}
	
	@RequestMapping("/deleteCommodity")
	@ResponseBody
	public Object deleteCommodity(TicketCommodityLink linkCommodity,String businessCode){
		RelevanceProduct relevanceProduct=relevanceProductService.viewRelevance(linkCommodity.getProd_id(),businessCode);
		linkCommodity.setBusiness_code(businessCode);
		if("xc".equals(linkCommodity.getCompany_code())){
			linkCommodity.setRel_prod_id(relevanceProduct.getProdIdXC());
		}else if("tn".equals(linkCommodity.getCompany_code())){
			linkCommodity.setRel_prod_id(relevanceProduct.getProdIdTN());
		}else if("tc".equals(linkCommodity.getCompany_code())){
			linkCommodity.setRel_prod_id(relevanceProduct.getProdIdTC());
		}else if("qnr".equals(linkCommodity.getCompany_code())){
			linkCommodity.setRel_prod_id(relevanceProduct.getProdIdQNR());
		}else if("el".equals(linkCommodity.getCompany_code())){
			linkCommodity.setRel_prod_id(relevanceProduct.getProdIdEL());
		}//新增美团
		else if("mt".equals(linkCommodity.getCompany_code())){
			linkCommodity.setRel_prod_id(relevanceProduct.getProdIdMT());
		}
		if(businessCode==null||"".equals(businessCode)||"TICKET".equals(businessCode)){
			if("xc".equals(linkCommodity.getCompany_code())){
				xcCommodityService.deleteLinkByProdCommId(linkCommodity.getRel_prod_id(), linkCommodity.getRel_commodity_id());
			}else if("tn".equals(linkCommodity.getCompany_code())){
				tnCommodityService.deleteLinkByProdCommId(linkCommodity.getRel_prod_id(), linkCommodity.getRel_commodity_id());
			}else if("tc".equals(linkCommodity.getCompany_code())){
				tcCommodityService.deleteLinkByProdCommId(linkCommodity.getRel_prod_id(), linkCommodity.getRel_commodity_id());
			}else if("qnr".equals(linkCommodity.getCompany_code())){
				qnrCommodityService.deleteLinkByProdCommId(linkCommodity.getRel_prod_id(), linkCommodity.getRel_commodity_id());
			}//新增美团
			else if("mt".equals(linkCommodity.getCompany_code())){
				mtCommodityService.deleteLinkByProdCommId(linkCommodity.getRel_prod_id(),linkCommodity.getRel_commodity_id());
			}
		}else if("HOTEL".equals(businessCode)){
			hotelCommodityService.deleteLinkd(linkCommodity.getCompany_code().toUpperCase()+"_C_CODE", linkCommodity.getRel_prod_id(),linkCommodity.getRel_commodity_id());
		}
		
		relevanceCommodityService.deleteCommodityLink(linkCommodity);
		
		return null;
	}
	
	public Map<String, Object> getResult() {
    	
        Map<String, Object> result = new HashMap<String, Object>();
        
        return result;
    }
}
